import logging
import datetime

# 设置日志级别
# logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s')

# 创建一个日志器
logger = logging.getLogger('my_logger')
logger.setLevel(logging.DEBUG)
# 设置处理器的格式化器
# formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
# 创建一个处理器，将日志输出到控制台
console_handler = logging.StreamHandler()
console_handler.setLevel(logging.DEBUG)  # 设置处理器的日志级别
console_handler.setFormatter(formatter)

# 将处理器添加到日志器
logger.addHandler(console_handler)